var downloadArray = Application.storage.get("tim_matthews.downloadScheduler.downloadArray", null);
if(downloadArray.length==0)
return;
var dm = Components.classes["@mozilla.org/download-manager;1"].getService(Components.interfaces.nsIDownloadManager);
var dlmgrWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("Download:Manager");
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var obj_Persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Components.interfaces.nsIWebBrowserPersist);
var scheduleWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("tim_matthews.downloadScheduler.schedWindow");
var sourceURI = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newURI(gContextMenu.linkURL, null, null);
var targetFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
var myURL = fp.fileURL.QueryInterface(Components.interfaces.nsIURL);
//alert(fp.file.path);
targetFile.initWithPath(fp.file.path);
var newFile = false;
if(!targetFile.exists())
{
targetFile.create(0x00,0644);
newFile = true;
}
var downloadArray = Application.storage.get("tim_matthews.downloadScheduler.downloadArray", null);
var scheduleSlot = {};
scheduleSlot.sourceURI = sourceURI;
scheduleSlot.targetURI = fp.fileURL;
scheduleSlot.targetFile = targetFile;
scheduleSlot.newFile = newFile;
downloadArray.push(scheduleSlot);
var scheduleWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("tim_matthews.downloadScheduler.schedWindow");